Skip to content

Add $indexStats stage tests#164

Open
danielfrankcom wants to merge 2 commits intodocumentdb:mainfrom
danielfrankcom:pr/indexStats
Open

Add $indexStats stage tests#164
danielfrankcom wants to merge 2 commits intodocumentdb:mainfrom
danielfrankcom:pr/indexStats

Conversation

@danielfrankcom
Copy link
Copy Markdown
Collaborator

@danielfrankcom danielfrankcom commented May 5, 2026

This change adds tests for the $indexStats aggregation stage operator.

I defined a new IndexStatsTestCase object which extends StageTestCase. These tests require indexes and custom collections in some cases, and I didn't want to pollute the more widely used StageTestCase with these.

Ref: #34

Signed-off-by: Daniel Frankcom <frankcom@amazon.com>
@danielfrankcom danielfrankcom requested a review from a team as a code owner May 5, 2026 18:34
@documentdb-triage-tool documentdb-triage-tool Bot added compatibility test Compatibility test related enhancement New feature or request labels May 5, 2026
@documentdb-triage-tool
Copy link
Copy Markdown

🤖 Auto-triaged by documentdb-triage-tool.

Applied: compatibility test, enhancement
Project fields suggested: Component test-coverage · Priority P2 · Effort L · Status Needs Review
Confidence: 0.85 (mixed)

Reasoning

component from path globs (test-coverage, test-framework); effort from diff stats (1379+0 LOC, 8 files); LLM: Adds new test cases for the $indexStats aggregation stage, introducing a new test case class within the test-coverage component.

If a label is wrong, remove it manually and ping @patty-chow so the rules can be tuned. The bot will not re-label items that already have component labels.

Signed-off-by: Daniel Frankcom <frankcom@amazon.com>
@danielfrankcom
Copy link
Copy Markdown
Collaborator Author

Pushed a small change to move the indexes definition to the shared StageTestCase class, as I found I also needed it for #167. Pushing this here will help avoid merge conflicts when these are both merged.

from documentdb_tests.framework.property_checks import Eq, Exists, IsType, NotExists
from documentdb_tests.framework.test_constants import INT64_ZERO

# Property [Top-Level Fields]: each output document contains the documented
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we have a test case verifying ops increment after index usage?

msg="Wildcard index key should use $** field path",
),
]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we have a test case a case like IndexModel([("arr", 1)]) on an array field to verify multi-key reporting, just for the sake of completeness.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compatibility test Compatibility test related enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants